const user = JSON.parse(sessionStorage.getItem("admin"));


//更新登录状态
function update_user() {

	//获取session 里的参数
	let str = sessionStorage.getItem("user");
	let data = JSON.parse(str);
	//获取userinfo的内容
	let info = $("#userinfo");

	if (str != null) {
		let info = document.getElementById("userinfo");
		//清空数据
		info.innerHTML = '';
		let a = document.createElement("a");
		a.setAttribute("href","mine.html");
		let span = document.createElement("span");
		let text = document.createTextNode(data.admin);
		let head_img = document.createElement("img");
		head_img.setAttribute("src", data.head_img);
		head_img.setAttribute("class", "head_img");
		span.appendChild(text);
		a.appendChild(span)
		a.appendChild(head_img)
		info.appendChild(a)

	}

}


//检测是否登录

function check_login(){
	
	if(user == null){
		alert("您当前还未登录");
		location.href = "index.html";
	}
}


//转换时间格式
function formatTime(seconds) {
  var hours = Math.floor(seconds / 3600);
  var minutes = Math.floor((seconds - hours * 3600) / 60);
  var seconds = Math.floor(seconds - hours * 3600 - minutes * 60);
  return hours + ":" + padZero(minutes) + ":" + padZero(seconds);
}

function padZero(num) {
  return num < 10 ? "0" + num : num;
}

